<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //利用构造函数创建对象
        //构造函数名字的首字母要大写
        //我们调用构造函数必须用new
        function Star(uname, type,blood) {
            this.name = uname; 
            this.type = type;
            this.blood = blood;
            this.attack = function(ka) {
                console.log(ka);
            }
        }
        var lp = new Star('廉颇', '力量型', '500血量'); 
        console.log(lp.name);
        console.log(lp.type);
        console.log(lp.blood);
        lp.attack('近战');
        var hy = new Star('后裔','攻击型','100血');
        hy.attack('远程');
        console.log(lp);
    </script>
</head>
<body>
    
</body>
</html>